package aybolit.core.objects.model;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Vadim
 * Date: 13.03.13
 * Time: 16:57
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class Operators implements Serializable {
    private int operId;

    @Column(name = "oper_id")
    @Id
    public int getOperId() {
        return operId;
    }

    public void setOperId(int operId) {
        this.operId = operId;
    }

    private String login;

    @Column(name = "login")
    @Basic
    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    private int operTypeId;

    @Column(name = "oper_type_id")
    @Basic
    public int getOperTypeId() {
        return operTypeId;
    }

    public void setOperTypeId(int operTypeId) {
        this.operTypeId = operTypeId;
    }

    private int operStatusId;

    @Column(name = "oper_status_id")
    @Basic
    public int getOperStatusId() {
        return operStatusId;
    }

    public void setOperStatusId(int operStatusId) {
        this.operStatusId = operStatusId;
    }

    private String password;

    @Column(name = "password")
    @Basic
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    private int hospitalId;

    @Column(name = "hospital_id")
    @Basic
    public int getHospitalId() {
        return hospitalId;
    }

    public void setHospitalId(int hospitalId) {
        this.hospitalId = hospitalId;
    }

    private int departmentId;

    @Column(name = "department_id")
    @Basic
    public int getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(int departmentId) {
        this.departmentId = departmentId;
    }

    private Timestamp timestamp;

    @Column(name = "timestamp_")
    @Basic
    public Timestamp getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Timestamp timestamp) {
        this.timestamp = timestamp;
    }

    private int deleted;

    @Column(name = "deleted")
    @Basic
    public int getDeleted() {
        return deleted;
    }

    public void setDeleted(int deleted) {
        this.deleted = deleted;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Operators operators = (Operators) o;

        if (deleted != operators.deleted) return false;
        if (departmentId != operators.departmentId) return false;
        if (hospitalId != operators.hospitalId) return false;
        if (operId != operators.operId) return false;
        if (operStatusId != operators.operStatusId) return false;
        if (operTypeId != operators.operTypeId) return false;
        if (login != null ? !login.equals(operators.login) : operators.login != null) return false;
        if (password != null ? !password.equals(operators.password) : operators.password != null) return false;
        if (timestamp != null ? !timestamp.equals(operators.timestamp) : operators.timestamp != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = operId;
        result = 31 * result + (login != null ? login.hashCode() : 0);
        result = 31 * result + operTypeId;
        result = 31 * result + operStatusId;
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + hospitalId;
        result = 31 * result + departmentId;
        result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
        result = 31 * result + deleted;
        return result;
    }

    private Departments departmentsByDepartmentId;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    public
   @JoinColumn(name = "department_id", referencedColumnName = "department_id", table = "operators")
    Departments getDepartmentsByDepartmentId() {
        return departmentsByDepartmentId;
    }

    public void setDepartmentsByDepartmentId(Departments departmentsByDepartmentId) {
        this.departmentsByDepartmentId = departmentsByDepartmentId;
    }

    private Hospitales hospitalesByHospitalId;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    public
    @JoinColumn(name = "hospital_id", referencedColumnName = "hospital_id", nullable = false, table = "operators")
    Hospitales getHospitalesByHospitalId() {
        return hospitalesByHospitalId;
    }

    public void setHospitalesByHospitalId(Hospitales hospitalesByHospitalId) {
        this.hospitalesByHospitalId = hospitalesByHospitalId;
    }

    private OperStatuses operStatusesByOperStatusId;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    public
    @JoinColumn(name = "oper_status_id", referencedColumnName = "oper_status_id", nullable = false, table = "operators")
    OperStatuses getOperStatusesByOperStatusId() {
        return operStatusesByOperStatusId;
    }

    public void setOperStatusesByOperStatusId(OperStatuses operStatusesByOperStatusId) {
        this.operStatusesByOperStatusId = operStatusesByOperStatusId;
    }

    private OperTypes operTypesByOperTypeId;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    public
    @JoinColumn(name = "oper_type_id", referencedColumnName = "oper_type_id", nullable = false, table = "operators")
    OperTypes getOperTypesByOperTypeId() {
        return operTypesByOperTypeId;
    }

    public void setOperTypesByOperTypeId(OperTypes operTypesByOperTypeId) {
        this.operTypesByOperTypeId = operTypesByOperTypeId;
    }

    private Collection<Patientes> patientesesByOperId;

    @OneToMany(mappedBy = "operatorsByOperatorId")
    public Collection<Patientes> getPatientesesByOperId() {
        return patientesesByOperId;
    }

    public void setPatientesesByOperId(Collection<Patientes> patientesesByOperId) {
        this.patientesesByOperId = patientesesByOperId;
    }

    private Collection<HealingDoctors> healingDoctorsesByOperId;

    @OneToMany(mappedBy = "operatorsByOperId")
    public Collection<HealingDoctors> getHealingDoctorsesByOperId() {
        return healingDoctorsesByOperId;
    }

    public void setHealingDoctorsesByOperId(Collection<HealingDoctors> healingDoctorsesByOperId) {
        this.healingDoctorsesByOperId = healingDoctorsesByOperId;
    }
}
